package com.js.service;

import com.js.dao.AdminDao;
import com.js.pojo.Category;
import com.js.pojo.News;
import com.js.pojo.User;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * author:JiangSong
 **/

@Service
public class AdminServiceImpl implements AdminService {
    @Resource
    private AdminDao adminDao;

    //根据用户名、密码查询用户
    @Transactional
    public User findUser(User user) {
        return adminDao.findUser(user);
    }

    @Override
    public int addUser(User user) {
        return adminDao.addUser(user);
    }

    //根据id删除新闻类型
    @Transactional
    public void categoryDelete(int id) {
        adminDao.categoryDelete(id);
    }

    //根据类型id查询
    @Transactional
    public Category findCategoryById(int id) {
        return adminDao.findCategoryById(id);
    }

    //根据id修改新闻类型
    @Transactional
    public void categoryUpdate(Category category) {
        adminDao.categoryUpdate(category);
    }

    //发布新闻类型
    @Transactional
    public void categoryAdd(Category category) {
        adminDao.categoryAdd(category);
    }

    //根据id删除新闻
    @Transactional
    public void newsDelete(int id){
        adminDao.newsDelete(id);
    }

    //更新新闻
    @Transactional
    public void newsUpdate(News news){
        adminDao.newsUpdate(news);
    }

    //发布新闻
    @Transactional
    public void newsAdd(News news) {
        adminDao.newsAdd(news);
    }
}
